package jmine.tec.utils.uppercase;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Mapa que armazena valores em upperCase ou não dependendo de configuação de upperCase.
 * 
 * @author Rafael Volpato
 * @date Jul 22, 2009
 * @param <K> Tipo da chave
 * @param <V> Tipo do valor
 */
public class UpperCaseConfigurableMap<K, V> implements Map<K, V> {

    private Map<K, V> delegate;

    /**
     * Construtor.
     * 
     * @param upperCase upperCase
     * @param originalMap originalMap
     */
    public UpperCaseConfigurableMap(boolean upperCase, Map<K, V> originalMap) {
        if (upperCase) {
            this.delegate = new UpperCaseValueMap<K, V>(originalMap);
        } else {
            this.delegate = new HashMap<K, V>(originalMap);
        }
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#clear()
     */
    public void clear() {
        this.delegate.clear();
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#containsKey(java.lang.Object)
     */
    public boolean containsKey(Object key) {
        return this.delegate.containsKey(key);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#containsValue(java.lang.Object)
     */
    public boolean containsValue(Object value) {
        return this.delegate.containsValue(value);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#entrySet()
     */
    public Set<java.util.Map.Entry<K, V>> entrySet() {
        return this.delegate.entrySet();
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object o) {
        return this.delegate.equals(o);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#get(java.lang.Object)
     */
    public V get(Object key) {
        return this.delegate.get(key);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#hashCode()
     */
    @Override
    public int hashCode() {
        return this.delegate.hashCode();
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#isEmpty()
     */
    public boolean isEmpty() {
        return this.delegate.isEmpty();
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#keySet()
     */
    public Set<K> keySet() {
        return this.delegate.keySet();
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#put(java.lang.Object, java.lang.Object)
     */
    public V put(K key, V value) {
        return this.delegate.put(key, value);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#putAll(java.util.Map)
     */
    public void putAll(Map<? extends K, ? extends V> t) {
        this.delegate.putAll(t);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#remove(java.lang.Object)
     */
    public V remove(Object key) {
        return this.delegate.remove(key);
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#size()
     */
    public int size() {
        return this.delegate.size();
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.util.Map#values()
     */
    public Collection<V> values() {
        return this.delegate.values();
    }
}
